#ifndef MACHINEHELPER_H
#define MACHINEHELPER_H


#include "base/errorcode.h"
#include "src/pubimp.h"
#include "../modbusControl/mbControl.h"
#include "tools.h"
#include <future>
#include "src/define/func_define.h"


class MachineHelper
{
public:
    static MachineHelper* GetInstance(){
        static QMutex mutex;
        static QScopedPointer<MachineHelper> inst;
        if (Q_UNLIKELY(!inst)) {
            mutex.lock();
            if (!inst) {
                inst.reset(new MachineHelper);
            }
            mutex.unlock();
        }
        return inst.data();
    }
    MachineHelper();

    MU_RETURNS ABSMove(MachineArgs,bool safeonly = false);  // 绝对运动，如果是安全模式
    MU_RETURNS RelativeMove(MachineArgs);

    MU_RETURNS setPara(int radius,int speed);


    void Connect();

    MU_RETURNS Close();
    std::shared_ptr<mbControl> _mb_ptr; // 电机指针

private:
    MU_RETURNS _open();
    void run();
};

#endif // MACHINEHELPER_H
